﻿/*--------------------------------------------------------------
 * Author : Shine K Velayudhan 
 ---------------------------------------------------------------*/
namespace IQN.Logging
{
    public sealed class TraceMessage : LogMessage
    {
        public string MessageSpec { get; set; }
        public object Param1 { get; set; }
        public object Param2 { get; set; }
        internal TraceMessage(string messageSource, MessageLevel messageLevel, string message, object param1, object param2)
            : base(messageSource, messageLevel)
        {
            this.MessageSpec = base.ClipAndClean(message, 128);
            this.Param1 = (param1 == null) ? string.Empty : param1;
            this.Param2 = (param2 == null) ? string.Empty : param2;
        }
        public override string MessageText
        {
            get
            {
                if (string.IsNullOrEmpty(this.MessageSpec))
                {
                    return string.Empty;
                }
                try
                {
                    return string.Format(this.MessageSpec, this.Param1, this.Param2);
                }
                catch
                {
                    return this.MessageSpec;
                }
            }
        }
        public override MessageType MessageType
        {
            get
            {
                return MessageType.Trace;
            }
        }
    }
}
